//
//  MsVideoUploadModel.m
//  NvSellerShowSDK
//
//  Created by roc on 17/9/12.
//  Copyright © 2017年 roc. All rights reserved.
//

#import "MsVideoUploadModel.h"

@implementation MsVideoUploadModel

- (NSString *)description {
    return [NSString stringWithFormat:@"%@-%@-%@--%i",self.corverImage,self.filePath,self.fileName,self.isSelected];
}

- (instancetype)initFromDict:(NSDictionary *)infoDict {
    if (self = [super init]) {
        self.fileName = [infoDict valueForKey:@"fileName"];
        self.corverImage = [UIImage imageWithData:[infoDict valueForKey:@"coverImage"]];
        self.filePath = [NSURL fileURLWithPath:[infoDict valueForKey:@"videoPath"]];
        self.fileDuration = [infoDict valueForKey:@"duration"];
        self.scale = [[infoDict valueForKey:@"videoScale"]intValue];
        self.themeUuid = [infoDict valueForKey:@"themeUUID"];
        self.fileSize = [[infoDict valueForKey:@"fileSize"] floatValue];
        self.isUploaded = YES;
        self.isSelected = NO;
    }
    return self;
}

- (NSMutableDictionary *)changeToDictionary {
    NSMutableDictionary *infoDict = [NSMutableDictionary dictionary];
    [infoDict setValue:self.fileName forKey:@"fileName"];
    [infoDict setValue:self.filePath.path forKey:@"videoPath"];
    [infoDict setValue:self.fileDuration forKey:@"duration"];
    [infoDict setValue:UIImagePNGRepresentation(self.corverImage) forKey:@"coverImage"];
    [infoDict setValue:[NSString stringWithFormat:@"%u",self.scale] forKey:@"videoScale"];
    [infoDict setValue:self.themeUuid forKey:@"themeUUID"];
    [infoDict setValue:[NSString stringWithFormat:@"%g",self.fileSize] forKey:@"fileSize"];
    return infoDict;
}

@end
